package org.balthie.cal;

import static org.balthie.cal.core.AbsCalculator.StandardInputerKey.Ctrl_Echo;
import static org.balthie.cal.core.AbsCalculator.StandardInputerKey.Ctrl_Help;
import static org.balthie.cal.core.AbsCalculator.StandardInputerKey.Ctrl_Redo;
import static org.balthie.cal.core.AbsCalculator.StandardInputerKey.Ctrl_Undo;
import static org.balthie.cal.core.AbsCalculator.StandardInputerKey.MathOpt_Div;
import static org.balthie.cal.core.AbsCalculator.StandardInputerKey.MathOpt_EQ;
import static org.balthie.cal.core.AbsCalculator.StandardInputerKey.MathOpt_Mul;

import java.util.Map;

import org.balthie.cal.core.IInputer;
import org.balthie.cal.impl.calculator.ConsoleinteractiveCalculator;
import org.balthie.cal.impl.calculator.MojoCalculator;

public class Application {
	public static void main(String[] args) throws InterruptedException {
		//	模拟一个有虚拟键盘，显示栏的计算器的使用过程（类似手机计算器）	
		mojoCalculatorRun();
		
		// 启动console交互计算器
		ConsoleinteractiveCalculator intactCal = new ConsoleinteractiveCalculator();
		intactCal.addButtonAlias(MathOpt_Mul, "x").addButtonAlias(MathOpt_Mul, "multiply").addButtonAlias(MathOpt_Div, "÷").addButtonAlias(MathOpt_Div, "➗").addButtonAlias(MathOpt_Div, "divide")
		.addButtonAlias(Ctrl_Echo, "print").addButtonAlias(Ctrl_Undo, "<").addButtonAlias(Ctrl_Redo, ">").addButtonAlias(Ctrl_Undo, ",").addButtonAlias(Ctrl_Redo, ".")
		.addButtonAlias(MathOpt_EQ, "").addButtonAlias(Ctrl_Help, "h");
		
		intactCal.start();
	}

	private static void mojoCalculatorRun() {
		// 模拟一个有虚拟键盘，显示栏的计算器的使用过程（类似手机计算器）
		MojoCalculator dc = new MojoCalculator();

		// 获取键盘按键
		Map<String, IInputer> keyboard = dc.getKeyboard();
		// TODO 渲染
		// KeyBoardView kview = build(keyboard);
		// kview.render();

		// 获取显示栏
		// IOuterPut out = dc.getDisplayBar();
		// TODO 渲染
		// DisplayBarView barView = build(out);

		keyboard.get(Ctrl_Help.getKey()).onClick();
		// Mojo 模拟用户操作
		// 模拟点击按钮"1"
		keyboard.get("1").onClick();
		// 模拟点击按钮"2"
		keyboard.get("二").onClick();

		// 模拟点击按钮"+"
		keyboard.get("➗").onClick();
		
		keyboard.get("叄").onClick();
		// 模拟点击按钮"Ⅳ"
		keyboard.get("Ⅳ").onClick();

		// 点击‘echo’按键
		keyboard.get("echo").onClick();

		// 模拟点击按钮"undo"
		keyboard.get("undo").onClick();

		// 点击‘echo’按键
		keyboard.get("echo").onClick();

		// 模拟点击按钮"0"
		keyboard.get("0").onClick();

		// 点击‘echo’按键
		keyboard.get("echo").onClick();

		// 模拟点击按钮"redo"
		keyboard.get("redo").onClick();

		// 点击‘echo’按键
		keyboard.get("echo").onClick();

		// 模拟点击按钮"="
		keyboard.get("=").onClick();
	}
}
